<template>
  <div>
    <h2>组合API-ref操作DOM或组件</h2>
    <hr>
    <!-- 2.绑定ref属性 -->
    <div ref='target'>你好</div>
    <button @click='handleClick'>点击</button>
  </div>
</template>
<script>
import { ref } from 'vue'

export default {
  name: 'App',
  setup () {
    // 1. 定义一个变量
    const target = ref(null)
    const handleClick = () => {
      // 3.通过target操作DOM元素
      console.log(target.value.innerHTML)
    }
    return { target, handleClick }
  }
}
</script>
